//
//  MHWaterFlowLayoutCell.m
//  ManHua
//
//  Created by 赵永泉 on 15/10/27.
//  Copyright © 2015年 蓝欧科技. All rights reserved.
//

#import "MHWaterFlowLayoutCell.h"
#import <UIImageView+WebCache.h>

@interface MHWaterFlowLayoutCell ()
@property (strong, nonatomic) UIImageView *picture;
@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *episodeLabel;

@end

@implementation MHWaterFlowLayoutCell

- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        self.picture = [[UIImageView alloc]init];
        self.picture.layer.cornerRadius = 8;
        self.picture.layer.masksToBounds = YES;
        [self.contentView addSubview:self.picture];
        
        self.titleLabel = [[UILabel alloc]init];
        self.titleLabel.font = [UIFont systemFontOfSize:12];
        self.titleLabel.backgroundColor = [UIColor clearColor];
        [self.contentView addSubview:self.titleLabel];
        
        self.episodeLabel = [[UILabel alloc]init];
        self.episodeLabel.font = [UIFont systemFontOfSize:12];
        self.episodeLabel.textAlignment = NSTextAlignmentRight;
        self.episodeLabel.backgroundColor = [UIColor clearColor];
        self.episodeLabel.textColor = [UIColor grayColor];
        [self.contentView addSubview:self.episodeLabel];
        
        self.contentView.layer.cornerRadius = 8;
        self.contentView.layer.masksToBounds = YES;
        self.contentView.clipsToBounds = YES;
        
        //阴影的颜色
        self.contentView.layer.shadowColor = [[UIColor colorWithWhite:0.783 alpha:1.000] CGColor];
        self.contentView.layer.shadowOffset = CGSizeMake(0, 0);
        //阴影透明度
        self.contentView.layer.shadowOpacity = 2.0;
        //阴影圆角度数
        self.contentView.layer.shadowRadius = 10.0;
        

    }
    return self;
}

- (void)setComicIntroct:(MHComicIntroduct *)comicIntroct
{
    _comicIntroct = comicIntroct;
    [self.picture sd_setImageWithURL:[NSURL URLWithString:comicIntroct.BookIconOtherURL]];
    self.titleLabel.text = comicIntroct.BookName;
    self.episodeLabel.text = comicIntroct.BookUpdateSection;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    self.picture.frame = CGRectMake(5, 5, self.bounds.size.width - 10, self.bounds.size.height - 40);
    self.titleLabel.frame = CGRectMake(5, CGRectGetMaxY(self.picture.frame) + 10, self.bounds.size.width / 2 - 5, 20);
    self.episodeLabel.frame = CGRectMake(self.bounds.size.width / 2 + 5, self.titleLabel.frame.origin.y, self.bounds.size.width / 2 - 10, 20);
}

@end
